mirror of
https://github.com/nasa/openmct.git
synced 2024-12-29 09:28:52 +00:00
[Plot] Initially implement synced pan/zoom stack
Initially implement a synchronized pan/zoom stack, which maintains the same domain axis bounds for all subplots in a stacked plot view, but allows each to have independent range axes. WTD-625.
This commit is contained in:
parent
9344809998
commit
0ce0517e09
79
platform/features/plot/src/elements/PlotPanZoomStackGroup.js
Normal file
79
platform/features/plot/src/elements/PlotPanZoomStackGroup.js
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*global define*/
|
||||||
|
|
||||||
|
define(
|
||||||
|
['./PlotPanZoomStack'],
|
||||||
|
function (PlotPanZoomStack) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function PlotPanZoomStackGroup(count) {
|
||||||
|
var stacks = [],
|
||||||
|
decoratedStacks = [],
|
||||||
|
i;
|
||||||
|
|
||||||
|
function pushPanZoom(origin, dimensions, index) {
|
||||||
|
stacks.forEach(function (stack, i) {
|
||||||
|
if (i === index) {
|
||||||
|
stack.pushPanZoom(origin, dimensions);
|
||||||
|
} else {
|
||||||
|
stack.pushPanZoom(
|
||||||
|
[ origin[0], stack.getOrigin[1] ],
|
||||||
|
[ dimensions[0], stack.getDimensions[1] ]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setBasePanZoom(origin, dimensions, index) {
|
||||||
|
stacks.forEach(function (stack, i) {
|
||||||
|
stack.setBasePanZoom(origin, dimensions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function popPanZoom() {
|
||||||
|
stacks.forEach(function (stack) {
|
||||||
|
stack.popPanZoom();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearPanZoom() {
|
||||||
|
stacks.forEach(function (stack) {
|
||||||
|
stack.popPanZoom();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function decorateStack(stack, index) {
|
||||||
|
var result = Object.create(stack);
|
||||||
|
|
||||||
|
result.pushPanZoom = function (origin, dimensions) {
|
||||||
|
pushPanZoom(origin, dimensions, index);
|
||||||
|
};
|
||||||
|
result.setBasePanZoom = function (origin, dimensions) {
|
||||||
|
|
||||||
|
};
|
||||||
|
result.popPanZoom = popPanZoom;
|
||||||
|
result.clearPanZoom = clearPanZoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < count; i += 1) {
|
||||||
|
stacks.push(new PlotPanZoomStack([], []));
|
||||||
|
}
|
||||||
|
decoratedStacks = stacks.map(decorateStack);
|
||||||
|
|
||||||
|
return {
|
||||||
|
popPanZoom: popPanZoom,
|
||||||
|
clearPanZoom: clearPanZoom,
|
||||||
|
getDepth: function () {
|
||||||
|
return stacks.length > 0 ?
|
||||||
|
stacks[0].getDepth() : 0;
|
||||||
|
},
|
||||||
|
getPanZoomStack: function (index) {
|
||||||
|
return decoratedStacks[index];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return PlotPanZoomStackGroup;
|
||||||
|
}
|
||||||
|
);
|
@ -45,7 +45,7 @@ define(
|
|||||||
return panZoomStack.getDepth() > 1;
|
return panZoomStack.getDepth() > 1;
|
||||||
},
|
},
|
||||||
stepBackPanZoom: function () {
|
stepBackPanZoom: function () {
|
||||||
panZoomStack.pop();
|
panZoomStack.popPanZoom();
|
||||||
subplot.update();
|
subplot.update();
|
||||||
},
|
},
|
||||||
unzoom: function () {
|
unzoom: function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user