mirror of
https://github.com/nasa/openmct.git
synced 2025-05-07 19:18:36 +00:00
[plot] set minimum marquee size (#2003)
Users must draw a marquee box with diagonal size of atleast 7.5 pixels. This prevents clicks from being translated to zooms on the plot. Because startMarquee triggers a plot history update. endMarquee must remove the plot history update when preventing marqueeZoom. This has a side effect of causing a requery for data, but is a simple enough solution for now. Fixes #2002.
This commit is contained in:
parent
865b99f445
commit
7d754ea143
@ -220,6 +220,7 @@ define([
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.marquee.end = this.positionOverPlot;
|
this.marquee.end = this.positionOverPlot;
|
||||||
|
this.marquee.endPixels = this.positionOverElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
MCTPlotController.prototype.startMarquee = function ($event) {
|
MCTPlotController.prototype.startMarquee = function ($event) {
|
||||||
@ -227,6 +228,8 @@ define([
|
|||||||
if (this.positionOverPlot) {
|
if (this.positionOverPlot) {
|
||||||
this.freeze();
|
this.freeze();
|
||||||
this.marquee = {
|
this.marquee = {
|
||||||
|
startPixels: this.positionOverElement,
|
||||||
|
endPixels: this.positionOverElement,
|
||||||
start: this.positionOverPlot,
|
start: this.positionOverPlot,
|
||||||
end: this.positionOverPlot,
|
end: this.positionOverPlot,
|
||||||
color: [1, 1, 1, 0.5]
|
color: [1, 1, 1, 0.5]
|
||||||
@ -237,8 +240,14 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
MCTPlotController.prototype.endMarquee = function () {
|
MCTPlotController.prototype.endMarquee = function () {
|
||||||
if (this.marquee.start.x !== this.marquee.end.x &&
|
var startPixels = this.marquee.startPixels;
|
||||||
this.marquee.start.y !== this.marquee.end.y) {
|
var endPixels = this.marquee.endPixels;
|
||||||
|
var marqueeDistance = Math.sqrt(
|
||||||
|
Math.pow(startPixels.x - endPixels.x, 2) +
|
||||||
|
Math.pow(startPixels.y - endPixels.y, 2)
|
||||||
|
);
|
||||||
|
// Don't zoom if mouse moved less than 7.5 pixels.
|
||||||
|
if (marqueeDistance > 7.5) {
|
||||||
this.$scope.xAxis.set('displayRange', {
|
this.$scope.xAxis.set('displayRange', {
|
||||||
min: Math.min(this.marquee.start.x, this.marquee.end.x),
|
min: Math.min(this.marquee.start.x, this.marquee.end.x),
|
||||||
max: Math.max(this.marquee.start.x, this.marquee.end.x)
|
max: Math.max(this.marquee.start.x, this.marquee.end.x)
|
||||||
@ -248,6 +257,10 @@ define([
|
|||||||
max: Math.max(this.marquee.start.y, this.marquee.end.y)
|
max: Math.max(this.marquee.start.y, this.marquee.end.y)
|
||||||
});
|
});
|
||||||
this.$scope.$emit('user:viewport:change:end');
|
this.$scope.$emit('user:viewport:change:end');
|
||||||
|
} else {
|
||||||
|
// A history entry is created by startMarquee, need to remove
|
||||||
|
// if marquee zoom doesn't occur.
|
||||||
|
this.back();
|
||||||
}
|
}
|
||||||
this.$scope.rectangles = [];
|
this.$scope.rectangles = [];
|
||||||
this.marquee = undefined;
|
this.marquee = undefined;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user